const express = require('express')

const app = express()

const { data } = require('./mock')

const fs = require('fs')

// 需要服务文件路径
app.use(express.static('../list'))

// 配置详情页路由
app.get('/detail', (req, res) => {
    res.end(fs.readFileSync('../list/detail.html'))
})

// 列表接口
app.get('/api/getList', (req, res) => {
    res.send({
        code:1,
        data
    })
})

app.get('/api/getDetail', (req, res) => {
    const { id } = req.query
    res.send({
        code: 1,
        data1: data.find(item => item.id === id)
    })
})


// 监听服务
app.listen(8080)

